/*
<Copyright (C) 2011 Dru Moore>

This file is part of demorecorder.

vlc-remote is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

demorecorder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with demorecorder.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAYPIPELINE_H
#define PLAYPIPELINE_H

#include <QObject>
#include <QString>
#include <gst/gst.h>

class PlayPipeline : public QObject
{
    Q_OBJECT
public:
    explicit PlayPipeline(QObject *parent = 0);
    PlayPipeline(QString name, GstElement *src);
    PlayPipeline(QString name, GstElement *src, GstElement *sink, bool canLink);

signals:
    void position_duration(long long position, long long duration);
    void end_of_stream();
    void stream_error(QString msg);

public slots:
    bool set_src(GstElement *bin); ///TODO MixerBin class
    void clear_src();
    static gboolean bus_callback(GstBus *bus, GstMessage *message, void* data);
    static gboolean pad_added(GstElement* comp, GstPad* srcPad, PlayPipeline* data);
    void get_duration_info();
    void play();
    void pause();
    void stop();

private:
    void construct_pipeline();
    long long get_current_time();

    GstPipeline *pipeline;
    GstElement *src;
    GstElement *sink;
    GstQuery *duration_query;
    GstQuery *position_query;
    long long position;
    long long duration;

};

#endif // PLAYPIPELINE_H
